package web;

public abstract class HttpApp {
    public abstract String getContext();

    public abstract void init();

    public abstract HttpService getHttpService(String path);

    public Response excute(Request request) {
        HttpService service = getHttpService(request.getPath());
        if (service != null) {
            if ("GET".equalsIgnoreCase(request.getMethod())) {
                Response response = new Response(200, "", "text/plain");
                service.doGet(request, response);
                return response;
            } else {
                Response response = new Response(200, "", "text/plain");
                service.doPost(request, response);
                return response;
            }

        } else {
            return new Response(404, "servcie Not found", "text/plain");
        }
    }
}
